//
//  OMTSDKCache.m
//  Pods
//
//  Created by yizhaorong on 2017/3/20.
//
//

#import "OMTAbstractCache.h"
#import "OMTAutoPurgaCache.h"

@implementation OMTAbstractCache

- (instancetype)init {
    if (self = [super init]) {
        _memCache = [[OMTAutoPurgaCache alloc] init];
        _memCache.name = @"com.onemt.default";
        
#if TARGET_OS_IPHONE
        // Subscribe to app events
        [[NSNotificationCenter defaultCenter] addObserver:self
                                                 selector:@selector(clearMemory)
                                                     name:UIApplicationDidReceiveMemoryWarningNotification
                                                   object:nil];
#endif
    }
    return self;
}

- (void)dealloc {
    [[NSNotificationCenter defaultCenter] removeObserver:self];
}

- (void)clearMemory {
    [self.memCache removeAllObjects];
}

@end
